package o;

import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import com.huawei.appgallery.foundation.ui.framework.titleframe.bean.SpinnerBaseTitleBean;
import com.huawei.appgallery.foundation.ui.framework.titleframe.bean.SpinnerInfo;
import com.huawei.appgallery.foundation.ui.framework.titleframe.bean.SpinnerItem;
import com.huawei.appmarket.framework.titleframe.title.SpinnerAdapter;
import com.huawei.appmarket.framework.titleframe.title.TitleSpinner;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

public class djd implements dix {
    private Activity ˊ;
    private djb ˋ;
    private ArrayAdapter<String> ˎ;
    private TitleSpinner ˏ;
    private SpinnerBaseTitleBean ॱ;
    private String ॱॱ = "";
    private boolean ᐝ = true;

    public djd(Activity activity, TitleSpinner titleSpinner, SpinnerBaseTitleBean spinnerBaseTitleBean) {
        this.ˊ = activity;
        this.ˏ = titleSpinner;
        this.ॱ = spinnerBaseTitleBean;
    }

    public boolean ˏ() {
        if (ˏ(this.ॱ.ˎ())) {
            Logger.e("SpinnerManager", "createSpinner: the spinner info is null or empty!");
            return false;
        }
        this.ॱॱ = this.ॱ.ˎ().ˊ();
        final List<SpinnerItem> ॱ = this.ॱ.ˎ().ॱ();
        List arrayList = new ArrayList();
        for (SpinnerItem ॱ2 : ॱ) {
            arrayList.add(ॱ2.ॱ());
        }
        this.ˎ = new SpinnerAdapter(this.ˊ, arrayList);
        this.ˏ.setAdapter(this.ˎ);
        this.ˏ.setOnItemSelectedListener(new OnItemSelectedListener(this) {
            final /* synthetic */ djd ॱ;

            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
                if (this.ॱ.ˋ == null) {
                    Logger.e("SpinnerManager", "iTitleDataChangedListener is null, illegal");
                } else if (this.ॱ.ᐝ) {
                    Logger.ˎ("SpinnerManager", "spinner initialization click");
                } else {
                    SpinnerItem spinnerItem = (SpinnerItem) ॱ.get(i);
                    this.ॱ.ˊ(i, spinnerItem);
                    this.ॱ.ˋ.ˊ(spinnerItem);
                }
            }

            public void onNothingSelected(AdapterView<?> adapterView) {
            }
        });
        this.ˏ.setExtendClick(this);
        return true;
    }

    public void ॱ() {
        this.ᐝ = false;
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("name", this.ॱॱ);
        if (ˏ(this.ॱ.ˎ())) {
            Logger.e("SpinnerManager", "extendsBI: the spinner info is null or empty!");
            return;
        }
        linkedHashMap.put("para", ((SpinnerItem) this.ॱ.ˎ().ॱ().get(0)).ˊ());
        linkedHashMap.put("service_type", Integer.valueOf(dgm.ˎ(this.ˊ)).toString());
        Logger.ˏ("SpinnerManager", "spinner extends click BI :" + linkedHashMap.size());
        dgh.ˋ("spinner_click", linkedHashMap);
    }

    private void ˊ(int i, SpinnerItem spinnerItem) {
        if (spinnerItem == null || spinnerItem.ॱ() == null || spinnerItem.ˊ() == null) {
            Logger.e("SpinnerManager", "ItemBI: spinnerItem is null or empty");
            return;
        }
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("itemname", spinnerItem.ॱ());
        linkedHashMap.put("itemindex", Integer.valueOf(i).toString());
        linkedHashMap.put("name", this.ॱॱ);
        linkedHashMap.put("para", spinnerItem.ˊ());
        linkedHashMap.put("service_type", Integer.valueOf(dgm.ˎ(this.ˊ)).toString());
        Logger.ˏ("SpinnerManager", "spinner item click BI :" + linkedHashMap.size());
        dgh.ˋ("spinner_item_click", linkedHashMap);
    }

    public void ˋ(SpinnerBaseTitleBean spinnerBaseTitleBean) {
        if (this.ˎ != null) {
            if (ˏ(spinnerBaseTitleBean.ˎ())) {
                Logger.e("SpinnerManager", "refreshAdapter: the spinner info is null or empty!");
                return;
            }
            this.ॱ = spinnerBaseTitleBean;
            this.ॱॱ = spinnerBaseTitleBean.ˎ().ˊ();
            List<SpinnerItem> ॱ = spinnerBaseTitleBean.ˎ().ॱ();
            this.ˎ.clear();
            for (SpinnerItem ॱ2 : ॱ) {
                this.ˎ.add(ॱ2.ॱ());
            }
            this.ˎ.notifyDataSetChanged();
        }
    }

    private boolean ˏ(SpinnerInfo spinnerInfo) {
        return spinnerInfo == null || CollectCheck.isEmpty(spinnerInfo.ॱ());
    }

    public void ˏ(djb o_djb) {
        this.ˋ = o_djb;
    }
}
